<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Voodoo Shader Framework: K:/VoodooShader/Framework/Logger.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Search" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>K:/VoodooShader/Framework/Logger.hpp</h1><a href="_logger_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**************************************************************************\</span>
<a name="l00002"></a>00002 <span class="comment">                        This file is part of the Voodoo Shader Framework.</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">        All source code,  binaries and  other original  content is </span>
<a name="l00005"></a>00005 <span class="comment">             Copyright (c) 2010 by Sean Sube, all rights reserved.</span>
<a name="l00006"></a>00006 <span class="comment">        Neither this  project nor  any portion may  be modified or</span>
<a name="l00007"></a>00007 <span class="comment">          distributed, or used for public or private demonstration</span>
<a name="l00008"></a>00008 <span class="comment">          or any other purpose without express written permission.</span>
<a name="l00009"></a>00009 <span class="comment">\**************************************************************************/</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#pragma once</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;windows.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;boost/format.hpp&gt;</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="_meta_8hpp.html">Meta.hpp</a>&quot;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="keyword">namespace </span>VoodooShader
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023         <span class="comment">// Forward-declare the Logger class so it can be used in log_format</span>
<a name="l00024"></a>00024         <span class="keyword">class </span>Logger;
<a name="l00025"></a>00025 
<a name="l00032"></a><a class="code" href="class_voodoo_shader_1_1_formatter.html">00032</a>         <span class="keyword">class </span><a class="code" href="_meta_8hpp.html#a64a3622e4b9bb13e6e7a451bfaa84a48">VOODOO_API</a> <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a>
<a name="l00033"></a>00033         {
<a name="l00034"></a>00034         <span class="keyword">public</span>:
<a name="l00040"></a>00040                 <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a>(<a class="code" href="class_voodoo_shader_1_1_logger.html" title="Logfile management class, capable of opening, closing, writing to and dumping log...">Logger</a> * parent);
<a name="l00041"></a>00041 
<a name="l00048"></a>00048                 <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a> &amp; Record(std::string fmtString);
<a name="l00049"></a>00049 
<a name="l00056"></a>00056                 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt; 
<a name="l00057"></a><a class="code" href="class_voodoo_shader_1_1_formatter.html#acd189536db2a1077fe75431b9acf868f">00057</a>                 <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a> &amp; With(T &amp; varString)
<a name="l00058"></a>00058                 {
<a name="l00059"></a>00059                         <span class="keywordflow">try</span>
<a name="l00060"></a>00060                         {
<a name="l00061"></a>00061                                 (this-&gt;mFmtObj) % (varString);
<a name="l00062"></a>00062                         } <span class="keywordflow">catch</span> ( ... ) { 
<a name="l00063"></a>00063                                 (this-&gt;mFmtObj) % (<span class="stringliteral">&quot;Invalid operand&quot;</span>);
<a name="l00064"></a>00064                         }
<a name="l00065"></a>00065                         <span class="keywordflow">return</span> (*<span class="keyword">this</span>);
<a name="l00066"></a>00066                 }
<a name="l00067"></a>00067 
<a name="l00074"></a>00074                 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt; 
<a name="l00075"></a><a class="code" href="class_voodoo_shader_1_1_formatter.html#a09a307c8137a95f55ed38dcd63727b08">00075</a>                 <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a> &amp; With(<span class="keyword">const</span> T &amp; varString)
<a name="l00076"></a>00076                 {
<a name="l00077"></a>00077                         <span class="keywordflow">try</span>
<a name="l00078"></a>00078                         {
<a name="l00079"></a>00079                                 (this-&gt;mFmtObj) % (varString);
<a name="l00080"></a>00080                         } <span class="keywordflow">catch</span> ( ... ) { 
<a name="l00081"></a>00081                                 (this-&gt;mFmtObj) % (<span class="stringliteral">&quot;Invalid operand&quot;</span>);
<a name="l00082"></a>00082                         }
<a name="l00083"></a>00083                         <span class="keywordflow">return</span> (*<span class="keyword">this</span>);
<a name="l00084"></a>00084                 }
<a name="l00085"></a>00085 
<a name="l00091"></a>00091                 <span class="keywordtype">void</span> Done(<span class="keywordtype">bool</span> timestamp = <span class="keyword">true</span>);
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="keyword">private</span>:
<a name="l00094"></a><a class="code" href="class_voodoo_shader_1_1_formatter.html#aec907d7883bb74ef0641f1b7ca2066c8">00094</a>                 <a class="code" href="class_voodoo_shader_1_1_logger.html" title="Logfile management class, capable of opening, closing, writing to and dumping log...">Logger</a> * mParent;
<a name="l00095"></a><a class="code" href="class_voodoo_shader_1_1_formatter.html#ae3949edb9f01381b532e17303d91d946">00095</a>                 boost::format mFmtObj;
<a name="l00096"></a>00096         };
<a name="l00097"></a>00097 
<a name="l00102"></a><a class="code" href="class_voodoo_shader_1_1_logger.html">00102</a>         <span class="keyword">class </span><a class="code" href="_meta_8hpp.html#a64a3622e4b9bb13e6e7a451bfaa84a48">VOODOO_API</a> <a class="code" href="class_voodoo_shader_1_1_logger.html" title="Logfile management class, capable of opening, closing, writing to and dumping log...">Logger</a>
<a name="l00103"></a>00103         {
<a name="l00104"></a>00104         <span class="keyword">public</span>:
<a name="l00113"></a>00113                 <a class="code" href="class_voodoo_shader_1_1_logger.html" title="Logfile management class, capable of opening, closing, writing to and dumping log...">Logger</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * filename, <span class="keywordtype">bool</span> append = <span class="keyword">false</span>);
<a name="l00114"></a>00114 
<a name="l00118"></a>00118                 ~<a class="code" href="class_voodoo_shader_1_1_logger.html" title="Logfile management class, capable of opening, closing, writing to and dumping log...">Logger</a>();
<a name="l00119"></a>00119 
<a name="l00124"></a>00124                 <span class="keywordtype">void</span> Timestamp();
<a name="l00125"></a>00125 
<a name="l00133"></a>00133                 <span class="keywordtype">void</span> Log(<span class="keyword">const</span> <span class="keywordtype">char</span> * msg, <span class="keywordtype">bool</span> timestamp = <span class="keyword">true</span>);
<a name="l00134"></a>00134 
<a name="l00142"></a>00142                 <span class="keywordtype">void</span> Log(std::string msg, <span class="keywordtype">bool</span> timestamp = <span class="keyword">true</span>);
<a name="l00143"></a>00143 
<a name="l00152"></a>00152                 <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a> &amp; Format(std::string message);
<a name="l00153"></a>00153 
<a name="l00164"></a>00164                 <span class="keywordtype">void</span> SetBufferSize(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bytes);
<a name="l00165"></a>00165 
<a name="l00175"></a>00175                 <span class="keywordtype">void</span> Dump();
<a name="l00176"></a>00176 
<a name="l00183"></a>00183                 <span class="keywordtype">bool</span> Open(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename);
<a name="l00184"></a>00184 
<a name="l00188"></a>00188                 <span class="keywordtype">void</span> Close();
<a name="l00189"></a>00189 
<a name="l00190"></a>00190         <span class="keyword">private</span>:
<a name="l00191"></a><a class="code" href="class_voodoo_shader_1_1_logger.html#a7573da40b99233381dc0e15d218a6eb2">00191</a>                 std::fstream mLogFile;
<a name="l00192"></a><a class="code" href="class_voodoo_shader_1_1_logger.html#a9fe444f5ac85a1f22753b22b5d415909">00192</a>                 <a class="code" href="class_voodoo_shader_1_1_formatter.html" title="Logging Format class.">Formatter</a> * mFormat;
<a name="l00193"></a><a class="code" href="class_voodoo_shader_1_1_logger.html#a6a70a3684a37809f6c7c3c634f917e5f">00193</a>                 tm * mLocalTime;
<a name="l00194"></a>00194         };
<a name="l00195"></a>00195 }
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Oct 14 23:18:33 2010 for Voodoo Shader Framework by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
